#ifndef _HTTP_CLIENT_INTERFACE_H_
#define _HTTP_CLIENT_INTERFACE_H_

#include "ofc/ofc_types.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct IHttpClientSocketTag IHttpClientSocket;

/**
 * 发送数据接口
 * @param sender: 接口指针
 * @param buf: 发送数据缓存
 * @param size: 发送数据长度
 * @return -1: 发送数据失败 >=0:实际发送数据长度
 */
typedef Int32 (*IHttpClientSocketDoSend)(IHttpClientSocket *sender, const UInt8 *buf, Int32 size);

/**
 * 接收数据接口
 * @param sender: 接口指针
 * @param buf: 接收数据缓存
 * @param size: 接收数据缓存长度
 * @return -1: 发送数据失败 >=0:实际接收数据长度
 */
typedef Int32 (*IHttpClientSocketDoRecv)(IHttpClientSocket *sender, UInt8 *buf, Int32 size);

/**
 * 会话连接
 * @param sender: 接口指针
 * @return
 */
typedef Int32 (*IHttpClientSocketDoConnect)(IHttpClientSocket *sender, const char *host, Int32 port);

/**
 * 断开会话连接
 * @param sender: 接口指针
 * @return
 */
typedef void (*IHttpClientSocketDoDisconnect)(IHttpClientSocket *sender);

struct IHttpClientSocketTag
{
    IHttpClientSocketDoConnect DoConnect;       ///< 建立连接
    IHttpClientSocketDoDisconnect DoDisconnect; ///< 关闭会话
    IHttpClientSocketDoSend DoDataSend;         ///< 发送数据流
    IHttpClientSocketDoRecv DoDataRecv;         ///< 接收消息
};

Int32 IHttpClientSocketSend(IHttpClientSocket *self, const UInt8 *buf, Int32 size);

Int32 IHttpClientSocketRecv(IHttpClientSocket *self, UInt8 *buf, Int32 size); 

Int32 IHttpClientSocketConnect(IHttpClientSocket *self, const char *host, Int32 port);

void IHttpClientSocketDisconnect(IHttpClientSocket *self);

#ifdef __cplusplus
}
#endif

#endif // _HTTP_CLIENT_SESSION_INTERFACE_H_
